package com.justgame.project.cloud.common.exception;


import com.justgame.project.cloud.common.constant.Const;
import org.springframework.http.HttpStatus;

/**
 * 自定义异常
 */
@SuppressWarnings("all")
public class Exc extends RuntimeException {
    private final static long serialVersionUID = Const.V;

    private String message;

    private Integer code = 500;

    public Exc(String message) {
        super(message);
        this.message = message;
    }

    public Exc(HttpStatus httpStatus){
        super(httpStatus.getReasonPhrase());
        this.message = httpStatus.getReasonPhrase();
        this.code = httpStatus.value();
    }

    public static void Thorw(HttpStatus httpStatus){
        throw new Exc(httpStatus);
    }

    public static Exc ReturnThorw(HttpStatus httpStatus){
        return new Exc(httpStatus);
    }

    public Exc(String message, Integer code) {
        super(message);
        this.message = message;
        this.code = code;
    }

    public Exc(String message, Throwable e) {
        super(message, e);
        this.message = message;
    }

    public Exc(String message, Integer code, Throwable e) {
        super(message, e);
        this.message = message;
        this.code = code;
    }

    @Override
    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

}
